package cn.appsys.interceptor;


import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;


public class SysInterceptor extends HandlerInterceptorAdapter {

    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        System.out.println("SysInterceptor...............");
        HttpSession session = request.getSession();
        String uname = (String) session.getAttribute("uname");
        if (null == uname) {
            response.sendRedirect(request.getContextPath() + "/error.jsp");
            return false;
        }
        return true;
    }
}
